package com.dongwu.manager.service.impl;

import com.dongwu.manager.dao.AdsClassifyDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dongwu.common.service.impl.BaseServiceImpl;
import com.dongwu.common.utils.UserUtils;
import com.dongwu.manager.entity.AdsClassify;
import com.dongwu.manager.service.AdsClassifyService;
import com.dongwu.security.service.IUserService;

import java.util.List;

@Service
public class AdsClassifyServiceImpl extends BaseServiceImpl<AdsClassify, String> implements AdsClassifyService {
	@Autowired
	private IUserService userService;

	@Autowired
	private AdsClassifyDao adsClassifyDao;
	
	@Override
	public AdsClassify save(AdsClassify entity) {

		if (entity.getUser() == null) {
			entity.setUser(userService.findByLoginName(UserUtils.getUserLoginName()));
		}
		return super.save(entity);
	}

	@Override
	public AdsClassify queryByCategoryId(Integer categoryId) {
		return adsClassifyDao.queryByCategoryId(categoryId);
	}

	@Override
	public List<AdsClassify> queryByType(String type) {
		return adsClassifyDao.queryByType(type);
	}
}
